import { Component, Input, AfterViewInit, OnChanges, OnInit } from '@angular/core';
import { GovernanceInsightModel } from '../models/companyGovernanceInsight.model';
import { AppComponent } from '../../../../../app.component';
import { LrtmService, LongRunningTaskTypeEnum } from '../../../../../framework/lrtm/lrtm.service';
import { UtilsService } from '../../../../../shared/services/utils.service';

@Component({
    selector: 'governance-insights',
    templateUrl: './governanceInsights.component.html',
})
export class GovernanceInsightsComponent implements OnInit {
    
    @Input() insights: GovernanceInsightModel[];

    @Input() companyId: string;

    constructor(
        private rootComponent: AppComponent,
        private lrtmService: LrtmService,
    ) {}

    ngOnInit() {

    }

    public downloadInsight(insight: GovernanceInsightModel){
        this.lrtmService
        .runTask(this.rootComponent, insight.fileName, LongRunningTaskTypeEnum.GovernancePDFS3, {
            fileId: insight.fileId,
            GovernancePdfType: 2,
            CompanyId: this.companyId
        }, true)
        .subscribe(report => {});
    }
}
